<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <!-- 
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
     -->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<{$baidu_map_key}>"></script>
    <title></title>
</head>

<body style="margin:0px;">
    <div style="width:100%;height:100%;" id="container"></div>
    <!-- 
    <div style="width:300px;margin:auto;">   
        <div id="container" 
            style="position: absolute;
                margin-top:30px; 
                width: 300px; 
                height: 500px; 
                top: 50; 
                border: 1px solid gray;
                overflow:hidden;">
        </div>
    </div>
     -->
</body>

<script type="text/javascript">
//通过浏览器获取当前位置并且表示出线路到达终点
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
    if(this.getStatus() == BMAP_STATUS_SUCCESS){
        //当前经纬度
        var start_lng = r.point.lng;
        var start_lat = r.point.lat;
        var map = new BMap.Map("container");
        map.enableScrollWheelZoom(); //启用滚轮放大缩小，也适用手机触摸，默认禁用。
        var localSearch = new BMap.LocalSearch(map);
        var keyword = "<{$ship_addr}>";
        
        localSearch.setSearchCompleteCallback(function (searchResult) {
            var poi = searchResult.getPoi(0);
            //通过地址获取终点经纬度
            var end_lng = poi.point.lng;
            var end_lat = poi.point.lat;
            //标识出驾车路线
            var p1 = new BMap.Point(start_lng,start_lat);
            var p2 = new BMap.Point(end_lng,end_lat);
            var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true}});
            driving.search(p1, p2);
            
        });
        localSearch.search(keyword);
    }else {
        alert('failed'+this.getStatus());
    }        
},{enableHighAccuracy: true})
</script>
